import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:intl/intl.dart';

class Page3 extends StatefulWidget {
  @override
  _Page3State createState() => _Page3State();
}

class _Page3State extends State<Page3> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // appBar: AppBar(
      //   title: Text('第三个页面'),
      // ),
      body: Container(
        decoration: BoxDecoration(
            image: DecorationImage(
              image: AssetImage('assets/img_2.png'), // 请替换为您的背景图像路径
              fit: BoxFit.cover,
            )),
        child: Center(
          child: BreathingCircleWidget(),
        ),
      ),
    );
  }
}

class BreathingCircleWidget extends StatefulWidget {
  @override
  _BreathingCircleWidgetState createState() => _BreathingCircleWidgetState();
}

class _BreathingCircleWidgetState extends State<BreathingCircleWidget> {
  bool _breathingIn = true;

  @override
  void initState() {
    super.initState();
    _startBreathingAnimation();
  }

  void _startBreathingAnimation() {
    Future.delayed(Duration(milliseconds: 500), () {
      setState(() {
        _breathingIn = !_breathingIn;
        _startBreathingAnimation();
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    final now = DateTime.now();
    final formattedTime = DateFormat.jm().format(now);
    final formattedDate = DateFormat.yMMMMd().format(now);

    return Stack(
      alignment: Alignment.center,
      children: [
        SpinKitDoubleBounce(
          color: Colors.blue,
          size: 300.0,
        ),
        Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              formattedTime,
              style: TextStyle(fontSize: 20),
            ),
            Text(
              formattedDate,
              style: TextStyle(fontSize: 20),
            ),
          ],
        ),
      ],
    );
  }
}
